home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr47 / wasm223.zip / DISPLAY.ASM < prev    next >
Assembly Source File  |  1993-05-04  |  26KB  |  858 lines

  1. ;************************;
  2. ; SESSION Display Output ;
  3. ;     By Eric Tauck      ;
  4. ;************************;
  5.  
  6. TABSIZE EQU     8               ;spaces per tabstop
  7.  
  8. mode    DW      TEXT8025        ;session video mode
  9. color   DW      0               ;(0=default, 1=color, 2=b/w)
  10.  
  11. ;--- window data structure
  12.  
  13. w_atr   EQU     0       ;attribute
  14. w_col   EQU     1       ;cursor column
  15. w_row   EQU     2       ;cursor row
  16. w_col1  EQU     3       ;left edge
  17. w_row1  EQU     4       ;top edge
  18. w_col2  EQU     5       ;right edge
  19. w_row2  EQU     6       ;bottom edge
  20. w_loc   EQU     7       ;saved cursor location pointer
  21. w_sav   EQU     9       ;saved cursor locations (room for 5)
  22. W_SIZE  EQU     19      ;bytes in data structure
  23.  
  24. ;========================================
  25. ; Initialize video.
  26.  
  27. Display_Init    PROC    NEAR
  28.  
  29. ;--- select video mode
  30.  
  31.         mov     al, BYTE mode   ;load mode
  32.         call    VidOpn          ;intialize video
  33.         jnc     disini1         ;jump if okay
  34.         mov     al, TEXT8025    ;use default mode
  35.         call    VidOpn          ;initialize video, assume success
  36.  
  37. ;--- save attribute
  38.  
  39. disini1 call    AtrGet          ;get attribute
  40.         mov     sattr, al       ;save it
  41.  
  42.         call    Display_Setup   ;set up display data
  43.         ret
  44.         ENDP
  45.  
  46. ;========================================
  47. ; Set up display data.
  48.  
  49. Display_SetUp   PROC    NEAR
  50.         push    di
  51.         push    si
  52.  
  53. ;--- set colors
  54.  
  55.         mov     ax, color               ;load color flag
  56.         dec     ax                      ;check if color = 1
  57.         jz      disset2
  58.         dec     ax                      ;check if color = 2
  59.         jz      disset1
  60.         call    VidCol                  ;get default
  61.         jc      disset2
  62.  
  63. disset1 mov     si, OFFSET attr_bw
  64.         jmps    disset3
  65. disset2 mov     si, OFFSET attr_col
  66. disset3 mov     di, OFFSET attr_start
  67.         mov     cx, ATTR_COUNT
  68.         cld
  69.         rep
  70.         movsb                           ;copy attributes
  71.  
  72. ;--- save number of rows and columns
  73.  
  74.         call    ModDim          ;get screen dimensions
  75.         mov     cols, al        ;save columns
  76.         mov     rows, ah        ;save rows
  77.  
  78. ;--- window tops and bottoms
  79.  
  80.         mov     bx, OFFSET window1      ;terminal window
  81.         mov     di, OFFSET window2      ;local window
  82.         mov     si, OFFSET window3      ;remote window
  83.  
  84.         mov     al, rows                ;number of rows
  85.         mov     ah, al
  86.         dec     al                      ;last row
  87.  
  88.         mov     BYTE [bx + w_row1], 0   ;terminal top
  89.         mov     [bx + w_row2], al       ;terminal bottom
  90.  
  91.         mov     BYTE [si + w_row1], 0   ;remote top
  92.         shr     ah
  93.         dec     ah
  94.         mov     [si + w_row2], ah       ;remote bottom
  95.  
  96.         inc     ah
  97.         inc     ah
  98.         mov     [di + w_row1], ah       ;local top
  99.         mov     [di + w_row2], al       ;local bottom
  100.  
  101. ;--- window edges
  102.  
  103.         mov     BYTE [bx + w_col1], 0   ;terminal left
  104.         mov     BYTE [di + w_col1], 0   ;local left
  105.         mov     BYTE [si + w_col1], 0   ;remote left
  106.         mov     al, cols                ;total columns
  107.         dec     al                      ;last column
  108.         mov     [bx + w_col2], al       ;terminal right
  109.         mov     [di + w_col2], al       ;local right
  110.         mov     [si + w_col2], al       ;remote right
  111.  
  112. ;--- window colors
  113.  
  114.         mov     al, attr_term                   ;
  115.         mov     BYTE [bx + w_atr], al           ;terminal
  116.         mov     al, attr_loc                    ;
  117.         mov     BYTE [di + w_atr], al           ;local
  118.         mov     al, attr_rem                    ;
  119.         mov     BYTE [si + w_atr], al           ;remote
  120.  
  121. ;--- cursor save locations
  122.  
  123.         lea     ax, [bx + w_sav]        ;start of save locations
  124.         mov     [bx + w_loc], ax
  125.         lea     ax, [di + w_sav]        ;start of save locations
  126.         mov     [di + w_loc], ax
  127.         lea     ax, [si + w_sav]        ;start of save locations
  128.         mov     [si + w_loc], ax
  129.  
  130. ;--- fix cursor if in proper video mode
  131.  
  132.         call    ModGet                  ;get mode
  133.         cmp     al, TEXT8025            ;check if standard mode
  134.         jne     disset4                 ;exit if not
  135.         call    CurFix                  ;cursor fix
  136.  
  137. disset4 pop     si
  138.         pop     di
  139.         ret
  140.         ENDP
  141.  
  142. ;========================================
  143. ; Restore the video state.
  144.  
  145. Display_Done    PROC    NEAR
  146.  
  147. ;--- clear screen
  148.  
  149.         mov     al, sattr       ;saved attribute
  150.         call    AtrSet          ;set attribute
  151.         call    ScrCls          ;clear screen
  152.  
  153. ;--- home cursor
  154.  
  155.         sub     ax, ax          ;row and column zero
  156.         call    CurMov          ;move to upper left
  157.         mov     al, 1
  158.         call    CurSet          ;turn cursor on
  159.  
  160. ;--- restore video mode
  161.  
  162.         call    VidClo          ;close video
  163.         ret
  164.         ENDP
  165.  
  166. ;========================================
  167. ; Set color attribute.
  168. ;
  169. ; In: AL= attribute (0=off, 1=bold,
  170. ;     5=blink); DI= window pointer.
  171.  
  172. Window_Attr PROC NEAR
  173.         mov     dl, [di+w_atr]  ;load attribute
  174.  
  175.         mov     ah, dl
  176.         and     ah, NOT (BLINK OR BOLD)
  177.         or      al, al
  178.         jz      winatr1
  179.  
  180.         mov     ah, dl
  181.         or      ah, BOLD
  182.         cmp     al, 1
  183.         je      winatr1
  184.  
  185.         mov     ah, dl
  186.         or      ah, BLINK
  187.         cmp     al, 5
  188.         je      winatr1
  189.  
  190. winatr1 mov     [di+w_atr], ah  ;save attribute
  191.         ret
  192.         ENDP
  193.  
  194. ;========================================
  195. ; Set foreground color.
  196. ;
  197. ; In: AL= color; DI= window pointer.
  198.  
  199. Window_Fore PROC NEAR
  200.         mov     ah, [di+w_atr]  ;load current attribute
  201.         and     ah, 0F8H        ;clear bits to set
  202.         or      al, ah          ;combine foreground and background
  203.         mov     [di+w_atr], al  ;save attribute
  204.         ret
  205.         ENDP
  206.  
  207. ;========================================
  208. ; Set background color.
  209. ;
  210. ; In: AL= color; DI= window pointer.
  211.  
  212. Window_Back PROC NEAR
  213.         mov     cl, 4           ;bits to shift
  214.         shl     al, cl          ;put color in background nibble
  215.         and     al, 70H         ;clear bold bit on new color
  216.         mov     ah, [di+w_atr]  ;load attribute
  217.         and     ah, 8FH         ;clear bits to set
  218.         or      al, ah          ;combine foreground and background
  219.         mov     [di+w_atr], al  ;save attribute
  220.         ret
  221.         ENDP
  222.  
  223. ;========================================
  224. ; Update the window cursor.
  225. ;
  226. ; In: DI= window pointer.
  227.  
  228. Window_Update   PROC    NEAR
  229.         mov     ax, [di + w_col]        ;cursor location
  230.         cmp     al, [di + w_col2]       ;check if too far right
  231.         jbe     winupd1                 ;jump if not
  232.         mov     al, [di + w_col2]       ;last column
  233. winupd1 push    ax
  234.         call    CurPos                  ;get current position
  235.         pop     dx
  236.         cmp     ax, dx                  ;check if already at position
  237.         je      winupd2                 ;exit if so
  238.         mov     ax, dx
  239.         call    CurMov                  ;position cursor
  240. winupd2 ret
  241.         ENDP
  242.  
  243. ;========================================
  244. ; Simulate newline if past end of right
  245. ; edge.
  246.  
  247. Window_Check PROC NEAR
  248.         mov     al, [di + w_col]        ;load column
  249.         cmp     al, [di + w_col2]       ;check if past end
  250.         jbe     winchk1
  251.         call    Window_Line             ;newline
  252.         mov     al, [di + w_col1]
  253.         mov     [di + w_col], al        ;set to first column
  254. winchk1 ret
  255.         ENDP
  256.  
  257. ;========================================
  258. ; Clear a window.
  259. ;
  260. ; In: DI= window pointer.
  261.  
  262. Window_Clear    PROC    NEAR
  263.         mov     al, [di + w_atr]        ;attribute
  264.         call    AtrSet                  ;set color
  265.         mov     bx, [di + w_col1]       ;upper left
  266.         mov     cx, [di + w_col2]       ;lower right
  267.         call    ScrClr                  ;clear screen
  268.         mov     ax, [di + w_col1]       ;home location
  269.         mov     [di + w_col], ax        ;new cursor location
  270.         call    Window_Update           ;position cursor
  271.         ret
  272.         ENDP
  273.  
  274. ;========================================
  275. ; Clear from cursor to end of line
  276.  
  277. Window_EOL PROC NEAR
  278.         call    Window_Check            ;fix cursor
  279.         call    Window_Update           ;move cursor
  280.  
  281.         mov     al, [di + w_atr]        ;attribute
  282.         call    AtrSet                  ;set color
  283.         mov     cl, [di+w_col2]         ;end column
  284.         sub     cl, [di+w_col]          ;minus current column
  285.         inc     cl                      ;at least one
  286.         mov     al, ' '                 ;space
  287.         call    WrtChrs                 ;display
  288.         ret
  289.         ENDP
  290.  
  291. ;========================================
  292. ; Clear from cursor to end of screen.
  293.  
  294. Window_EOS PROC NEAR
  295.         call    Window_EOL              ;clear to end of line
  296.  
  297.         mov     al, [di + w_atr]        ;attribute
  298.         call    AtrSet                  ;set color
  299.         mov     bh, [di + w_row]        ;current row
  300.         cmp     bh, [di + w_row2]       ;check if bottom
  301.         je      wineos1
  302.         inc     bh
  303.         sub     bl, bl                  ;column zero
  304.         mov     cx, [di + w_col2]       ;lower right
  305.         call    ScrClr                  ;clear screen
  306. wineos1 ret
  307.         ENDP
  308.  
  309. ;========================================
  310. ; Return the current cursor position.
  311. ;
  312. ; In: DI= window pointer.
  313. ;
  314. ; Out: AH,AL= row/column.
  315.  
  316. Window_Position PROC NEAR
  317.         mov     ax, [di+w_col]          ;physical location
  318.         sub     ax, [di+w_col1]         ;adjust for window
  319.         ret
  320.         ENDP
  321.  
  322. ;========================================
  323. ; Move cursor
  324. ;
  325. ; In: AH,AL= row/column; DI= window
  326. ;     pointer.
  327.  
  328. Window_Move PROC NEAR
  329.         add     ax, [di+w_col1]         ;add upper left offset
  330.         mov     [di+w_col], ax          ;save location
  331.         call    Window_Update           ;move cursor
  332.         ret
  333.         ENDP
  334.  
  335. ;========================================
  336. ; Move the cursor up.
  337. ;
  338. ; In: AL= rows to move up; DI= window
  339. ;     pointer.
  340.  
  341. Window_Up PROC  NEAR
  342.         mov     ah, [di+w_row]          ;current location
  343.         sub     ah, [di+w_row1]         ;to edge of window
  344.         cmp     al, ah                  ;check maximum move
  345.         jbe     winup1                  ;jump if okay
  346.         mov     al, ah                  ;set to max
  347. winup1  sub     [di+w_row], al          ;adjust row
  348.         call    Window_Update           ;move cursor
  349.         ret
  350.         ENDP
  351.  
  352. ;========================================
  353. ; Move the cursor down.
  354. ;
  355. ; In: AL= rows to move down; DI= window
  356. ;     pointer.
  357.  
  358. Window_Down PROC NEAR
  359.         mov     ah, [di+w_row2]         ;current location
  360.         sub     ah, [di+w_row]          ;to edge of window
  361.         cmp     al, ah                  ;check maximum move
  362.         jbe     windwn1                 ;jump if okay
  363.         mov     al, ah                  ;set to max
  364. windwn1 add     [di+w_row], al          ;adjust row
  365.         call    Window_Update           ;move cursor
  366.         ret
  367.         ENDP
  368.  
  369. ;========================================
  370. ; Move the cursor left.
  371. ;
  372. ; In: AL= columns to move left; DI=
  373. ;     window pointer.
  374.  
  375. Window_Left PROC  NEAR
  376.         mov     ah, [di+w_col]          ;current location
  377.         sub     ah, [di+w_col1]         ;to edge of window
  378.         jnc     winlef1                 ;jump if okay
  379.         sub     ah, ah                  ;past edge, pretend at edge
  380. winlef1 cmp     al, ah                  ;check maximum move
  381.         jbe     winlef2                 ;jump if okay
  382.         mov     al, ah                  ;set to max
  383. winlef2 sub     [di+w_col], al          ;adjust column
  384.         call    Window_Update           ;move cursor
  385.         ret
  386.         ENDP
  387.  
  388. ;========================================
  389. ; Move the cursor right.
  390. ;
  391. ; In: AL= columns to move right; DI=
  392. ;     window pointer.
  393.  
  394. Window_Right PROC NEAR
  395.         mov     ah, [di+w_col2]         ;current location
  396.         sub     ah, [di+w_col]          ;to edge of window
  397.         cmp     al, ah                  ;check maximum move
  398.         jbe     winrig1                 ;jump if okay
  399.         mov     al, ah                  ;set to max
  400. winrig1 add     [di+w_col], al          ;adjust column
  401.         call    Window_Update           ;move cursor
  402.         ret
  403.         ENDP
  404.  
  405. ;========================================
  406. ; Save cursor location.
  407. ;
  408. ; In: DI= window pointer.
  409.  
  410. Window_Save PROC NEAR
  411.         mov     bx, [di+w_loc]          ;load save pointer
  412.         push    WORD [di+w_col]
  413.         pop     WORD [bx]               ;copy current location
  414.         inc     bx                      ;
  415.         inc     bx                      ;point to next location
  416.         mov     [di+w_loc], bx          ;save for next save
  417.         ret
  418.         ENDP
  419.  
  420. ;========================================
  421. ; Restore cursor location.
  422. ;
  423. ; In: DI= window pointer.
  424.  
  425. Window_Rest PROC NEAR
  426.         mov     bx, [di+w_loc]          ;load save pointer
  427.         dec     bx                      ;
  428.         dec     bx                      ;point to last location
  429.         mov     [di+w_loc], bx          ;save for next restore
  430.         mov     ax, [bx]                ;load saved location
  431.         mov     [di+w_col], ax          ;set location
  432.         call    Window_Update           ;move cursor
  433.         ret
  434.         ENDP
  435.  
  436. ;========================================
  437. ; Display a character.
  438. ;
  439. ; In: DI= window pointer; AL= character.
  440.  
  441. Window_Type     PROC    NEAR
  442.  
  443. ;--- check if beep
  444.  
  445.         cmp     al, BEL         ;beep
  446.         jne     wintyp1         ;jump if not
  447.         call    Beep_Std        ;beep
  448.         ret
  449.  
  450. ;--- check if backspace
  451.  
  452. wintyp1 cmp     al, BS          ;backspace
  453.         jne     wintyp2         ;jump if not
  454.         call    Window_Bkspc    ;backspace
  455.         ret
  456.  
  457. ;--- check if tab
  458.  
  459. wintyp2 cmp     al, TAB         ;tab
  460.         jne     wintyp3         ;jump if not
  461.         call    Window_Tab      ;tab
  462.         ret
  463.  
  464. ;--- check if linefeed
  465.  
  466. wintyp3 cmp     al, LF                  ;check if linefeed
  467.         jne     wintyp4                 ;jump if not
  468.         call    Window_Line             ;do linefeed
  469.         ret
  470.  
  471. ;--- check if carriage return
  472.  
  473. wintyp4 cmp     al, CR                  ;check if carriage return
  474.         jne     wintyp5                 ;jump if not
  475.         mov     al, [di + w_col1]       ;first column
  476.         mov     [di + w_col], al        ;move cursor there
  477.         call    Window_Update           ;update cursor
  478.         ret
  479.  
  480. ;--- check if formfeed
  481.  
  482. wintyp5 cmp     al, FF                  ;check if formfeed
  483.         jne     wintyp6                 ;jump if not
  484.         call    Window_Clear            ;update cursor
  485.         ret
  486.  
  487. ;--- must be character
  488.  
  489. wintyp6 push    ax
  490.         mov     al, [di + w_atr]        ;color
  491.         call    AtrSet                  ;set color
  492.         call    Window_Check            ;fix cursor
  493.         call    Window_Update           ;position cursor
  494.         pop     ax
  495.         call    WrtChr                  ;display character
  496.  
  497. ;--- advance cursor
  498.  
  499.         inc     BYTE [di + w_col]       ;increment column
  500.         call    Window_Update           ;update cursor
  501.         ret
  502.         ENDP
  503.  
  504. ;========================================
  505. ; Backspace.
  506. ;
  507. ; In: DI= window pointer.
  508.  
  509. Window_BkSpc    PROC    NEAR
  510.         call    Window_Check            ;fix cursor
  511.  
  512. ;--- check if at edge
  513.  
  514.         mov     ax, [di + w_col]        ;current location
  515.         cmp     al, [di + w_col1]       ;check if column zero
  516.         jz      winbks3                 ;jump if so
  517.         dec     al                      ;previous column
  518.  
  519. ;--- do a backspace
  520.  
  521. winbks1 mov     [di + w_col], ax        ;save location
  522.         call    CurMov                  ;position cursor
  523.         mov     al, [di + w_atr]        ;color
  524.         call    AtrSet                  ;set color
  525.         mov     al, ' '                 ;blank
  526.         call    WrtChr                  ;display character
  527.         call    Window_Update           ;update cursor
  528. winbks2 ret
  529.  
  530. ;--- at left edge
  531.  
  532. winbks3 cmp     ah, [di + w_row1]       ;check if at top row
  533.         je      winbks2                 ;jump if so
  534.         dec     ah                      ;previous row
  535.         mov     al, [di + w_col2]       ;load left column
  536.         jmps    winbks1
  537.         ENDP
  538.  
  539. ;========================================
  540. ; Tab.
  541. ;
  542. ; In: DI= window pointer.
  543.  
  544. Window_Tab      PROC    NEAR
  545.         call    Window_Check            ;fix cursor
  546.         mov     al, [di + w_col]        ;current column
  547.         sub     al, [di + w_col1]       ;column number
  548.         sub     ah, ah
  549.         mov     dl, TABSIZE             ;spaces per tab
  550.         div     dl
  551.         sub     dl, ah                  ;spaces to advance
  552.         add     [di + w_col], dl        ;advance cursor
  553.         call    Window_Update           ;update cursor
  554.         ret
  555.         ENDP
  556.  
  557. ;========================================
  558. ; Display a newline.
  559. ;
  560. ; In: DI= window pointer.
  561.  
  562. Window_Line     PROC    NEAR
  563.  
  564. ;--- check if scroll
  565.  
  566.         mov     ax, [di + w_col]        ;current location
  567.         inc     ah                      ;next row
  568.  
  569.         cmp     ah, [di + w_row2]       ;check if bottom of screen
  570.         jbe     winlin1
  571.  
  572.         mov     ah, [di + w_row2]       ;use last row
  573.         push    ax
  574.         mov     ax, [di + w_col1]       ;upper left
  575.         mov     bx, ax
  576.         inc     bh
  577.         mov     cx, [di + w_col2]       ;lower right
  578.         call    ScrCpy                  ;scroll screen
  579.         mov     al, [di + w_atr]        ;attribute
  580.         call    AtrSet                  ;set it
  581.         mov     al, [di + w_col1]       ;left
  582.         mov     ah, [di + w_row2]       ;bottom
  583.         call    CurMov                  ;position cursor
  584.         mov     cl, [di + w_col2]       ;right edge
  585.         sub     cl, [di + w_col1]       ;minus left edge
  586.         inc     cl                      ;adjust
  587.         mov     al, ' '                 ;space
  588.         call    WrtChrs                 ;blank line
  589.         pop     ax
  590.  
  591. ;--- save cursor location
  592.  
  593. winlin1 mov     [di + w_col], ax        ;save cursor location
  594.         call    Window_Update           ;update cursor
  595.         ret
  596.         ENDP
  597.  
  598. ;========================================
  599. ; Display an ASCIIZ string using a
  600. ; specific attribute.
  601. ;
  602. ; In: DI= window pointer; AX= string
  603. ;     address; DL= attribute.
  604.  
  605. Window_String PROC      NEAR
  606.         push    si
  607.         mov     si, ax          ;put address in SI
  608.         mov     al, [di+w_atr]  ;save attribute
  609.         mov     [di+w_atr], dl  ;new attribute
  610.         push    ax
  611.         jmps    winstr2
  612.  
  613. winstr1 call    Window_Type     ;display character
  614. winstr2 cld
  615.         lodsb                   ;load byte
  616.         or      al, al          ;check if end of string
  617.         jnz     winstr1         ;loop back if not end
  618.  
  619.         pop     ax
  620.         mov     [di+w_atr], al
  621.         pop     si
  622.         ret
  623.         ENDP
  624.  
  625. ;========================================
  626. ; Clear the remote input window.
  627.  
  628. Remote_Clear    PROC    NEAR
  629.         push    di
  630.         mov     di, rem_win     ;load remote window pointer
  631.         call    Window_Clear    ;clear window
  632.         pop     di
  633.         ret
  634.         ENDP
  635.  
  636. ;========================================
  637. ; Type a character to the remote input
  638. ; window.
  639. ;
  640. ; In: AL= character.
  641.  
  642. Remote_Type     PROC    NEAR
  643.         push    di
  644.         mov     di, rem_win     ;load remote window pointer
  645.         call    Window_Type     ;type character
  646.         pop     di
  647.         ret
  648.         ENDP
  649.  
  650. ;========================================
  651. ; Clear the local input window.
  652.  
  653. Local_Clear     PROC    NEAR
  654.         push    di
  655.         mov     di, loc_win     ;load local window pointer
  656.         cmp     di, rem_win     ;check if same window
  657.         je      locclr1         ;skip clear if so
  658.         call    Window_Clear    ;clear window
  659. locclr1 pop     di
  660.         ret
  661.         ENDP
  662.  
  663. ;========================================
  664. ; Type a character to the local input
  665. ; window.
  666. ;
  667. ; In: AL= character.
  668.  
  669. Local_Type      PROC    NEAR
  670.         push    di
  671.         mov     di, loc_win     ;load local window pointer
  672.         call    Window_Type     ;type character
  673.         pop     di
  674.         ret
  675.         ENDP
  676.  
  677. ;========================================
  678. ; Display a system message.
  679.  
  680. System_String   PROC    NEAR
  681.         push    di
  682.         mov     di, rem_win     ;remote window pointer
  683.         mov     dl, attr_mess   ;attribute
  684.         call    Window_String   ;type string
  685.         pop     di
  686.         ret
  687.         ENDP
  688.  
  689. ;========================================
  690. ; Display a debug message.
  691.  
  692. Debug_String    PROC    NEAR
  693.         push    di
  694.         mov     di, loc_win     ;local window pointer
  695.         mov     dl, attr_debug  ;attribute
  696.         call    Window_String   ;type string
  697.         pop     di
  698.         ret
  699.         ENDP
  700.  
  701. ;========================================
  702. ; Clear both windows.
  703.  
  704. Clear_Both      PROC    NEAR
  705.         call    Remote_Clear    ;clear remote window
  706.         call    Local_Clear     ;clear local window
  707.         ret
  708.         ENDP
  709.  
  710. ;========================================
  711. ; Merge the screen (i.e. single window
  712. ; mode).
  713.  
  714. Screen_Merge    PROC    NEAR
  715.  
  716. ;--- copy remote attribute to main attribute
  717.  
  718.         mov     al, window3 + w_atr     ;
  719.         mov     window1+ w_atr, al      ;copy attribute
  720.  
  721. ;--- merge
  722.  
  723.         mov     ax, OFFSET window1      ;local window
  724.         mov     loc_win, ax             ;save it
  725.         mov     rem_win, ax             ;save it
  726.         call    Remote_Clear            ;clear screen
  727.         ret
  728.         ENDP
  729.  
  730. ;========================================
  731. ; Split the screen.
  732.  
  733. Screen_Split    PROC    NEAR
  734.  
  735. ;--- copy main attribute to remote attribute
  736.  
  737.         mov     al, window1 + w_atr     ;
  738.         mov     window3 + w_atr, al     ;copy attribute
  739.  
  740. ;--- set up windows
  741.  
  742.         mov     ax, OFFSET window2      ;local window
  743.         mov     loc_win, ax             ;save it
  744.         mov     ax, OFFSET window3      ;remote window
  745.         mov     rem_win, ax             ;save it
  746.  
  747. ;--- draw center line
  748.  
  749.         mov     bx, rem_win             ;remote window
  750.         mov     ah, [bx + w_row2]       ;bottom row
  751.         inc     ah                      ;next row
  752.         sub     al, al                  ;column zero
  753.         call    CurMov                  ;move cursor
  754.         mov     al, attr_line           ;line color
  755.         call    AtrSet                  ;set color
  756.         mov     al, 205                 ;double line
  757.         mov     cl, cols                ;number of columns
  758.         call    WrtChrs                 ;display line
  759.  
  760.         call    Clear_Both              ;clear both windows
  761.         ret
  762.         ENDP
  763.  
  764. ;========================================
  765. ; Save the current screen.
  766.  
  767. Screen_Save     PROC    NEAR
  768.  
  769. ;--- save cursor position
  770.  
  771.         call    CurPos          ;cursor position
  772.         mov     WORD s_col, ax  ;save it
  773.  
  774. ;--- save screen
  775.  
  776.         sub     bx, bx          ;upper left
  777.         mov     cx, WORD cols   ;load rows and columns
  778.         dec     ch              ;end row
  779.         dec     cl              ;end column
  780.         push    bx
  781.         push    cx
  782.         call    ScrSiz          ;get bytes needed
  783.         call    MemAll          ;allocate memory
  784.         pop     cx
  785.         pop     bx
  786.         jc      scrsav1         ;jump if error
  787.         mov     s_seg, ax       ;save segment
  788.         mov     dx, ax
  789.         sub     ax, ax
  790.         call    ScrGet          ;copy screen
  791.         clc
  792. scrsav1 ret
  793.         ENDP
  794.  
  795. ;========================================
  796. ; Save the current screen.
  797.  
  798. Screen_Restore  PROC    NEAR
  799.  
  800. ;--- restore screen
  801.  
  802.         sub     bx, bx          ;upper left
  803.         mov     cx, WORD cols   ;load rows and columns
  804.         dec     ch              ;end row
  805.         dec     cl              ;end column
  806.         mov     dx, s_seg       ;segment
  807.         sub     ax, ax          ;offset
  808.         call    ScrPut          ;restore screen
  809.         mov     ax, s_seg       ;segment
  810.         call    MemRel          ;release memory
  811.  
  812. ;--- restore cursor
  813.  
  814.         mov     ax, WORD s_col  ;load row and column
  815.         call    CurMov          ;position cursor
  816.         mov     al, 1           ;non-zero
  817.         call    CurSet          ;turn cursor on
  818.         ret
  819.         ENDP
  820.  
  821. ;========================================
  822. ; Display a screen of data.
  823.  
  824. Screen_Display  PROC    NEAR
  825.         mov     si, ax
  826.  
  827.         sub     al, al
  828.         call    CurSet          ;cursor off
  829.         call    Screen_Save     ;save screen
  830.  
  831.         mov     al, attr_help   ;help attribute
  832.         call    AtrSet          ;set color
  833.  
  834.         call    ScrCls          ;clear screen
  835.         sub     ax, ax
  836.         call    CurMov          ;home cursor
  837.         jmps    scrdis2         ;enter loop
  838.  
  839. scrdis1 call    WrtChr          ;display character
  840.         call    CurAdv          ;advance cursor
  841. scrdis2 cld
  842.         lodsb                   ;load next character
  843.         or      al, al          ;check if end
  844.         jz      scrdis3
  845.         cmp     al, 10          ;check if new line
  846.         jne     scrdis1
  847.  
  848.         call    CurPos          ;get position
  849.         inc     ah              ;next row
  850.         sub     al, al          ;column zero
  851.         call    CurMov          ;move cursor
  852.         jmps    scrdis2         ;loop back
  853.  
  854. scrdis3 call    KeyWai          ;wait for key
  855.         call    Screen_Restore  ;restore screen
  856.         ret
  857.         ENDP
  858.